function DatumView() {
    var _this = this;
    var page;
    _this.page_size = 10;

    // init
    _this.init = function(_page) {
        page = _page;
        _this.initTable();
    }

    _this.initTable = function() {
        var list_url = appPath + "/attachment/attachmentList";
        page.init("attachment_form", list_url, "attachment_list", "attachment_page", 1, _this.page_size);
        page.goPage(1);
        page.list = function(dataList){
            _this.obj = dataList;
            if(dataList == null){
                return;
            }
            var len = dataList.length;
            var inner = "", item;
            // 组装数据
            for(var i=0; i< len; i++) {
                item = dataList[i];
                // 组装数据
                inner += "<tr>";
                inner += "<td>"+(parseInt(i)+1)+"</td>";
                inner += "<td><input type='checkbox' value='"+item.intId+"'/></td>";
                inner += "<td><span class=\"text-orange tooltip\" data-length='30'>"+item.varLocalName+"</span></td>";
                inner += '<td>';
                inner += '<a href="javascript:datumView.preView(\''+item.intId+'\');" class="a a-info">预览</a> ';
                inner += '<a href="javascript:datumView.download(\''+item.intId+'\');" class="a a-view">下载</a> ';
                inner += "</td>";
                inner += "</tr>";
            }
            return inner;
        }

    };

    // 预览
    _this.preView = function (intId) {
        $.ajax({
            url: appPath + "/attachment/isTranscoding",
            data: {
                "intId": intId
            },
            dataType: "json",
            async: true,
            type: "GET",
            success: function (data) {
                var result = eval(data).result;
                if (result == true) {
                    layer_show("附件预览", appPath+"/attachment/view?intId=" + intId, "800", "600");
                } else if (result == false) {
                    //转码失败
                    layer.msg("转码中...", {icon: 7});
                } else if (result == "error") {
                    //接口报错
                    layer.msg("系统异常,请联系管理员!", {icon: 7});
                }
            }
        });
    }

    // 下载
    _this.download = function (intId) {
        location.href = appPath+"/attachment/downloadAttachment?attachmentId=" + intId;
    }

}

var datumView = new DatumView();